package quotation.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class MybatisConfig {
    /**
     * 插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        //防止全表更新
        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
        //自动填充公共字段
        //1自己设置了值的属性不会自动填充
        //2加了fill = FieldFill.INSERT、UPDATE、INSERT_UPDATE的字段也不自动填充，填充方式将由你自己写的handler处理）
        interceptor.addInnerInterceptor(new SqlInnerInterceptor());
        return interceptor;
    }
}
